package cn.itcast.mapper;

import cn.itcast.DTO.PageQueryDTO;
import cn.itcast.entity.Room;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoomMapper {
    List<Room> page(PageQueryDTO dto);

    @Insert("insert into room(status,number,size,introduce,price,deposit,occupancy_rate) " +
            " values(#{status},#{number},#{size},#{introduce},#{price},#{deposit},#{occupancyRate})")
    void insert(Room room);

    @Delete("delete from room where id=#{id}")
    void delete(Long id);

    @Select("select * from room where id=#{id}")
    Room findById(Long id);

    void update(Room room);

    @Select("select * from room")
    List<Room> selectAll();

    @Select("select id from room where number = #{roomNo}")
    Integer findIdByRoomNo(String roomNo);

    @Select("select * from room where number = #{number}")
    Room find(String number);
}
